{extend name="public:index"/} {block name="title"}{:sysconf('title')}{/block} {block name="content"}
<div class="whtop">
    <div class="top">
        <p class="p1">
            <a href="javascript:history.back(-1)"></a>
        </p>
        <p class="p2">余额提现</p>
        <p class="p3"></p>
    </div>
</div>
<div style="height:2rem;"></div>
<div class="zhu_ce1">
    <form id="wash_form">
        <div class="c-login-input">
            <div class="form-group">
                <label class="f16">提现金额</label>
                <div class="pull-left">
                    <input type="number" name="money" placeholder="请输入提现金额">
                </div>
            </div>
            <div class="form-group">
                <label class="f16">银行卡</label>
                <div class="pull-left"><select name="bankid" id="yinhang">
                    <option value="">请选择</option>
                    {foreach name="bank" item="vo"}
                    <option value="{$vo.id}">{$vo['bank']} {$vo['account']}</option>
                    {/foreach} </select></div>
            </div>
            <div class="form-group"><label class="f16">手机号</label>
                <div class="pull-left"><input type="number" name="mobile" placeholder="请输入手机号码"></div>
            </div>
            <div class="form-group"><label class="f16">验证码</label>
                <div class="pull-left"><input name="code" placeholder="请输入验证码">
                    <div class="yanz"><input type="button" id="sendcode" value="获取验证码" /></div>
                </div>
            </div>
            <div class="Next_"><input style="outline:none;margin-top:2rem;" type="button" value="申请提现"></div>
            <span style="color:#ff0000;padding:0.5rem;display:block;text-align: center;">税金{:sysconf('cash_cost')}%，手续费每笔{:sysconf('cash_tax')}元。</span>
        </div>
    </form>
</div>
<script type="text/javascript">
    $(".Next_").click(function() {
        // var name = $("input[name=name]").val();
        var mobile = $("input[name=mobile]").val();
        var code = $("input[name=code]").val();
        var bankid = $("select[name=bankid]").val();
        var money = $("input[name=money]").val();
        if (mobile == '' || code == '' || bankid == '' || money == '') {
            layer.msg('请完善提现资料', {
                icon: 5
            });
            return false;
        }
        $.ajax({
            type: "post",
            url: "{:url('user/cash')}",
            data: {
                'mobile': mobile,
                'code': code,
                'bankid': bankid,
                'money': money
            },
            dataType: "json",
            success: function(data) {
                if (data.code == 0) {
                    layer.msg(data.msg, {
                        icon: 6,
                        time: 1000
                    }, function() {
                        history.back();
                    })
                } else {
                    layer.msg(data.msg, {
                        icon: 5
                    });
                }
            },
            error: function() {
                layer.msg("网络延迟，发送失败", {
                    icon: 5
                });
            }
        });
    });
    $("#sendcode").click(function() {
        var mobile = $("input[name=mobile]").val();
        var sendbtn = $(this);
        var mobilereg = /^((13|14|15|17|18)\d{9})$/;
        if (mobile == "" || !mobilereg.test(mobile)) {
            layer.msg("请输入正确的手机号码", {
                icon: 5
            });
            return false;
        }
        $.ajax({
            type: "POST",
            url: "{:url('Common/sendSms')}",
            data: {
                'mobile': mobile
            },
            dataType: "JSON",
            success: function(data) {
                if (data.code == 0) {
                    $("#sendcode").prop("disabled", true);
                    var tstart = 59;
                    var internow = setInterval(function() {
                        tstart--;
                        sendbtn.val(tstart + '秒后重新获取');
                        if (tstart <= 0) {
                            clearInterval(internow);
                            sendbtn.val('获取短信验证码');
                            $("#sendcode").prop("disabled", false);
                        }
                    }, 1000);
                } else {
                    layer.msg(data.msg);
                    $("#sendcode").prop("disabled", false);
                }
            },
            error: function() {
                layer.msg("网络延迟，发送失败");
                $("#sendcode").prop("disabled", false);
            }
        });
    });
</script>
{/block}